#pragma once 
#include <string>
#include <sstream>
#include <fstream>
#include <ctime>
#include <time.h>
#include <cmath>
using namespace std;

#include <d3d9.h>
#pragma comment(lib, "d3d9.lib")
#include <d3dx9.h>
#pragma comment(lib, "d3dx9.lib")
#include <dxerr.h>
#pragma comment(lib, "dxerr.lib")
#define DIRECTINPUT_VERSION 0x0800
#include <dinput.h>
#pragma comment(lib, "dinput8.lib")
#pragma comment(lib, "dxguid.lib")

enum eColors
{
	RED,
	GREEN, 
	BLUE,
	YELLOW,
	BLACK
};
enum eMouseButtons							
{
	LEFT,
	RIGHT,
	MIDDLE
};
enum eObjectTypes
{
	TYPE_INVALID,
	TYPE_ZONE,
	TYPE_BUTTON,
	TYPE_MENUPANEL,
	TYPE_MAP,
	TYPE_SIZE
};
enum eGameStates
{
	GS_INVALID,		//The Object was improperly set.
	GS_ALWAYS,		//The Object will always show.
	GS_GAMEPLAY,	//The game is in play without any menus open
	GS_mWORLD,		//The Object shows when World Button is clicked.
	GS_mOPTIONS,	//The Object shows when Options Button is clicked.
	GS_mMUTATE,		//The Object shows when Mutate Button is clicked.
	GS_mZONE,		//The Game is displaying a country's menu
	GS_PAUSED,		//The Object shows when the game is paused
	GS_QUIT
};
enum eMovementDir
{
	DIR_INVALID,
	DIR_UP,		//Move Up
	DIR_DOWN,	//Move Down
	DIR_LEFT,	//Move Left
	DIR_RIGHT,	//Move Right
	DIR_SWIDTHU,	//Scale Width Up
	DIR_SWIDTHD,	//Scale Width Down
	DIR_SHEIGHTU,	//Scale Height Up
	DIR_SHEIGHTD,	//Scale Height Down
	DIR_SALLU,		//Scale Height Up
	DIR_AALLD,		//Scall All Down
	DIR_SIZE
};
enum eService
{
	SER_ROADS,
	SER_RAILS,
	SER_PORTS,
	SER_HOSPITALS,
	SERVICE_SIZE
};
enum eAfflictions
{
	AFL_EARTHQUAKE,
	AFL_HURRICANE,
	AFL_FLOODING,
	AFL_RIOTS,
	AFL_MASSCHAOS,
	AFFLICT_SIZE
};
enum eAffairs
{
	AFR_WALLSUP,
	AFR_MARTIALLAW,
	AFR_MASKHANDOUTS,
	AFR_WATERHANDOUTS,
	AFR_BROADCASTS,
	AFR_VACCINE,
	AFR_EX_INSECTS,
	AFR_EX_ANIMALS,
	AFR_EX_INFECTED,
	AFFAIR_SIZE
};
enum eZones
{
	ZONE_KAJHTAI,
	ZONE_KHATOUM,
	ZONE_AEMPIS,
	ZONE_FAURRIEAST,
	ZONE_FAURRIWEST,
	ZONE_VALDUTAN,
	ZONE_VERINWEST,
	ZONE_VERINEAST,
	ZONE_VERINCENTER,
	ZONE_NEGEWEST,
	ZONE_NEGEEAST,
	ZONE_MARIANIYAH,
	ZONE_SIASYA,
	ZONE_SANKT,
	ZONE_VALUSERRH,
	ZONE_SIZE
};
enum eTextures
{
	TEX_KAJHTAI,
	TEX_KHATOUM,
	TEX_AEMPIS,
	TEX_FAURRIEAST,
	TEX_FAURRIWEST,
	TEX_VALDUTAN,
	TEX_VERINWEST,
	TEX_VERINEAST,
	TEX_VERINCENTER,
	TEX_NEGEWEST,
	TEX_NEGEEAST,
	TEX_MARIANIYAH,
	TEX_SIASYA,
	TEX_SANKT,
	TEX_VALUSERRH,
	TEX_BUTTON,
	TEX_MENUPANEL,
	TEX_MAP,
	TEX_BAR,		//Dock for the menubuttons at the bottom
	TEX_SIZE
};


struct PrintBox
{
	//=====VARIABLES
	RECT				Location;
	//ID3DXFont*			FontDevice;			
	string				Content;
	//======CONSTRUCT
	PrintBox(){};
	PrintBox(float,float,float,float,string);
	//=====RENDER
	void Draw();
};
class Timer		
{
private:

	__int64 TimeAtNow;		//Current time in MS
	__int64	TimeAtThen;		//Last time in MS			
	double  DeltaT;			//The difference between

	void SetTimer()				
	{
		DeltaT = 0;
		QueryPerformanceCounter((LARGE_INTEGER*)&TimeAtThen);
	}
	Timer()								
		:DeltaT(NULL),
		TimeAtNow(0),
		TimeAtThen(0)
	{
		SetTimer();
	}

public:

	static Timer* Into()	//Returns pointer to the singleton instance
	{
		static Timer Timer;
		return &Timer;
	}
	bool bQueryDeltaT(float Specifier)
	{
		QueryPerformanceCounter((LARGE_INTEGER*)&TimeAtNow);	//Fill it
		DeltaT += (TimeAtNow - TimeAtThen);						//Add the difference to elapsed time
		TimeAtThen = TimeAtNow;									//The old value becomes the new

		if((double)Specifier < DeltaT)						
		{
			SetTimer();
			return true;
		}
		return false;
	}
};


//#define SHAME
//#define ThisIsHard

const  int			ScreenW	= 1000;
const  int			ScreenH	= 700;
static int			c_eiGameState = GS_GAMEPLAY;

